﻿using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace November {
    class ScalablePictureBox : PictureBox {
        protected override void OnPaint(PaintEventArgs paintEventArgs) {
            if (Image != null && (Width < Image.Width || Height < Image.Height)) {
                paintEventArgs.Graphics.InterpolationMode = InterpolationMode.Bilinear;
            }
            else {
                paintEventArgs.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
            }
            base.OnPaint(paintEventArgs);
        }
    }
}
